%This file creates the data for Figure 5c and saves it in
%\Replication_files\mat_files\fig5c_data.mat

clear
cd ../mat_files

for rho_g_2=0:0.02:0.7
    cd ../m_files
    set_parameters(2.48,0,0.98+rho_g_2,-rho_g_2,0.8,15,0,1,8);
    cd ../mod_files
    dynare a15_markups.mod
    L=length(mu_u);
    sign_var=sign(mu_u(1:L-1).*mu_u(2:L));
    [I,temp]=find(sign_var<0);
    d=min(I);
    if mu_u(1)<=0 
        d=0;
    end
    cd ../mat_files
    if rho_g_2==0;
        duration=d;
    else
        load('fig5c_data.mat');
        duration=[duration d];
    end
    save('fig5c_data.mat','duration');
end

cd ../m_files